extends PlayerState

#var screensize

# Called when the node enters the scene tree for the first time.
func _ready():
#	screensize = get_viewport().size
	pass

func update():
	if Input.is_action_pressed("ui_right"):
		player.velocity.x = 1
		player.get_node("Position2D").scale.x = 1
	if Input.is_action_pressed("ui_left"):
		player.velocity.x = -1
		player.get_node("Position2D").scale.x = -1
	if is_equal_approx(0,(Input.get_action_strength("ui_right")-Input.get_action_strength("ui_left"))):
		state_machine.transition_to("PlayerIdle")
		
#	player.position += player.velocity * _delta
#	player.position.x = clamp(player.position.x,0,screensize.x)
#	player.position.y = clamp(player.position.y,0,screensize.y)
	
func enter():
	player.get_node("AnimationPlayer").play("move")
